<template>
  <div class="web">
    <div class="webLeft">
      <menuleft :menuList="menuList" @handleMenu="handleMenu" :menuFlag="showFlag" />
    </div>
    <div class="webRight">
      <weekly v-if="showFlag == '8'" />
      <annals v-if="showFlag == '9'" />
      <personalProject v-if="showFlag == '35'" />
      <weeklyAnomaly v-if="showFlag == '37'" />
      <companyPlan v-if="showFlag == '38'" />
      <empWork v-if="showFlag == '39'" />
      <empSummary v-if="showFlag == '40'" />
      <deptPlan v-if="showFlag == '49'"></deptPlan>
    </div>
  </div>
</template>

<script>
import weekly from "./weekly"; //周报
import annals from "./annals"; //年报
import personalProject from "./personalProject"; //个人项目
import weeklyAnomaly from "./weeklyAnomaly";
import { getUserAuthResourceList } from "@/service/Api.js"; //接口
import menuleft from "@/components/menuItem/menuleft.vue";
import empWork from "./empWork"; //工作管理
import companyPlan from "./companyPlan.vue"; //计划管理
import empSummary from "./empSummary.vue"; //总结管理
import deptPlan from "./deptPlan.vue";//部门计划与总结
export default {
  components: {
    weekly,
    annals,
    menuleft,
    personalProject,
    weeklyAnomaly,
    empWork,
    companyPlan,
    empSummary,
    deptPlan
  },
  name: "projectMent",
  data() {
    return {
      menuList: [
        {
          name: "周报管理",
          id: 2,
          children: [],
        },
      ],
      showFlag: "",
      id: this.$route.params.id,
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      // 获取当前角色下的二级列表
      let menuId = parseInt(this.menuList[0].id)
      getUserAuthResourceList(menuId).then((res) => {
        if (res.code == 0) {
          this.menuList[0].children = res.data;
          if (this.id == undefined) {
            this.showFlag = res.data[0].id.toString();
          } else if (this.id == 39) {
            this.showFlag = res.data[res.data.length - 3].id.toString();
          } else if (this.id == 40) {
            this.showFlag = res.data[res.data.length - 2].id.toString();
          }else {
            this.showFlag = "35"
          }
        } else {
          this.$message.error(`${res.data}`);
        }
      });
    },
    handleCommon(name, row, idx) {
      if (this[name]) {
        this[name](row, idx);
      }
    },
    handleMenu(id) {
      this.showFlag = id;
    },
  },
};
</script>

<style scoped>

</style>
